home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _520C8611218244C8BC1373995A8D08E6 < prev    next >
Encoding:
Text File  |  2004-01-06  |  23.4 KB  |  741 lines

  1. -- Default behaviour - implements all the system callbacks and does something
  2. -- this is so that any enemy has a behaviour to fallback to
  3. --------------------------
  4. -- DO NOT MODIFY THIS BEHAVIOUR
  5.  
  6. AIBehaviour.DEFAULT = {
  7.     Name = "DEFAULT",
  8.  
  9.  
  10.     START_CLIMBING = function ( self, entity, sender)
  11.         AI:MakePuppetIgnorant(entity.id,1);
  12.     end,
  13.  
  14.     STOP_CLIMBING = function ( self, entity, sender)
  15.         AI:MakePuppetIgnorant(entity.id,0);
  16.     end,
  17.  
  18.  
  19.     MAKE_ME_IGNORANT = function ( self, entity, sender)
  20.         AI:MakePuppetIgnorant(entity.id,1);
  21.     end,
  22.     
  23.     MAKE_ME_UNIGNORANT = function ( self, entity, sender)
  24.  
  25.         AI:MakePuppetIgnorant(entity.id,0);
  26.     end,
  27.  
  28.     -- cool retreat tactic
  29.     RETREAT_NOW = function ( self, entity, sender)
  30.  
  31.         local retreat_spot = AI:FindObjectOfType(entity.id,50,AIAnchor.RETREAT_HERE);
  32.         if (retreat_spot) then 
  33.             entity:SelectPipe(0,"retreat_to_spot",retreat_spot);
  34.         else
  35.             entity:SelectPipe(0,"retreat_back");
  36.         end
  37.         entity:Readibility("RETREATING_NOW",1);
  38.     end,
  39.  
  40.     RETREAT_NOW_PHASE2 = function ( self, entity, sender)
  41.  
  42.         local retreat_spot = AI:FindObjectOfType(entity.id,50,AIAnchor.RETREAT_HERE);
  43.         if (retreat_spot) then 
  44.             entity:SelectPipe(0,"retreat_to_spot_phase2",retreat_spot);
  45.         else
  46.             entity:SelectPipe(0,"retreat_back_phase2");
  47.         end
  48.     
  49.         entity:Readibility("RETREATING_NOW",1);
  50.     end,
  51.  
  52.     PROVIDE_COVERING_FIRE = function ( self, entity, sender)
  53.         entity:SelectPipe(0,"dumb_shoot");
  54.         entity:Readibility("PROVIDING_COVER",1);
  55.     end,
  56.  
  57.     -- cool rush tactic
  58.     RUSH_TARGET = function ( self, entity, sender)
  59.         entity:SelectPipe(0,"rush_player");
  60.         entity:Readibility("AI_AGGRESSIVE",1);
  61.  
  62.     end,
  63.  
  64.     STOP_RUSH = function ( self, entity, sender)
  65.         entity:TriggerEvent(AIEVENT_CLEAR);
  66.     end,
  67.     
  68.  
  69.     START_SWIMMING = function ( self, entity, sender)
  70.         entity:SelectPipe(0,"swim_inplace");
  71.     end,
  72.  
  73.     GO_INTO_WAIT_STATE = function ( self, entity, sender)
  74.         entity:SelectPipe(0,"wait_state");
  75.     end,
  76.  
  77.     SPECIAL_FOLLOW = function (self, entity, sender)
  78.         entity.AI_SpecialBehaviour = "SPECIAL_FOLLOW";
  79.         entity:SelectPipe(0,"val_follow");
  80.         entity:Readibility("FOLLOWING_PLAYER",1);
  81.         AI:MakePuppetIgnorant(entity.id,0);
  82.     end,
  83.  
  84.     SPECIAL_GODUMB = function (self, entity, sender)
  85.         entity.AI_SpecialBehaviour = "SPECIAL_GODUMB";
  86.         entity:DoSomethingInteresting();
  87.         AI:MakePuppetIgnorant(entity.id,1);
  88.     end,
  89.  
  90.     SPECIAL_STOPALL = function (self, entity, sender)
  91.         entity.AI_SpecialBehaviour = nil;
  92.         --entity.EventToCall = "OnSpawn";
  93.         entity:SelectPipe(0,"standingthere");
  94.         AI:MakePuppetIgnorant(entity.id,0);
  95.     end,
  96.  
  97.     SPECIAL_LEAD = function (self, entity, sender)
  98.         entity.AI_SpecialBehaviour = "SPECIAL_LEAD";
  99.         entity:SelectPipe(0,"standingthere");
  100.         entity.LEADING = nil;
  101.         entity.EventToCall = "OnCloseContact";
  102.         entity:Readibility("LETS_CONTINUE",1);
  103.         AI:MakePuppetIgnorant(entity.id,0);
  104.     end,
  105.  
  106.     SPECIAL_HOLD = function (self, entity, sender)
  107.         entity.AI_SpecialBehaviour = "SPECIAL_HOLD";
  108.         local spot = AI:FindObjectOfType(entity:GetPos(),50,AIAnchor.SPECIAL_HOLD_SPOT);
  109.         if (spot == nil) then 
  110.             Hud:AddMessage("========================== UNACCEPTABLE ERROR ====================");
  111.             Hud:AddMessage("No SPECIAL_HOLD_SPOT anchor for entity "..entity:GetName());
  112.             Hud:AddMessage("========================== UNACCEPTABLE ERROR ====================");
  113.         end
  114.         entity:SelectPipe(0,"hold_spot",spot);
  115.         AI:MakePuppetIgnorant(entity.id,0);
  116.     end,
  117.  
  118.  
  119.     CANNOT_RESUME_SPECIAL_BEHAVIOUR = function(self,entity,sender)
  120.         if (entity.AI_SpecialBehaviour) then
  121.             entity:Readibility("THERE_IS_STILL_SOMEONE",1);
  122.         end
  123.     end,
  124.  
  125.     RESUME_SPECIAL_BEHAVIOUR = function(self,entity,sender)
  126.         if (entity.AI_SpecialBehaviour) then
  127.             entity:TriggerEvent(AIEVENT_CLEARSOUNDEVENTS);
  128.             AI:Signal(0,1,entity.AI_SpecialBehaviour,entity.id);
  129.         end
  130.     end,
  131.  
  132.     --- Everyone is now able to respond to reinforcements
  133.     ---------------------------------------------
  134.     AISF_CallForHelp = function ( self, entity, sender)
  135.         local guy_should_reinforce = AI:FindObjectOfType(entity.id,5,AIAnchor.RESPOND_TO_REINFORCEMENT);        
  136.         if (guy_should_reinforce) then 
  137.             --AI:Signal(0,1,"SWITCH_TO_RUN_TO_FRIEND",entity.id);
  138.             entity:MakeAlerted();
  139.             entity:SelectPipe(0,"cover_beacon_pindown");
  140.             entity:InsertSubpipe(0,"offer_join_team_to",sender.id);
  141.             if (entity.AI_GunOut==nil) then
  142.                 entity:InsertSubpipe(0,"DRAW_GUN");    
  143.             end
  144.         end
  145.     end,
  146.     ---------------------------------------------
  147.  
  148.  
  149.     APPLY_IMPULSE_TO_ENVIRONMENT = function(self,entity,sender)
  150.         entity:InsertAnimationPipe("kick_barrel");
  151.         entity.ImpulseParameters.pos = entity:GetPos();
  152.         entity.ImpulseParameters.pos.z = entity.ImpulseParameters.pos.z-1;
  153.         entity:ApplyImpulseToEnvironment(entity.ImpulseParameters);
  154.     end,
  155.  
  156.  
  157.     OnVehicleDanger = function(self,entity,sender)
  158.         entity:InsertSubpipe(0,"backoff_from_lastop",sender.id);
  159.     end,
  160.  
  161.     HIDE_END_EFFECT = function(self,entity,sender)
  162.         entity:StartAnimation(0,"rollfwd",4);
  163.     end,
  164.  
  165.     Smoking = function(self,entity,sender)
  166.         entity.EventToCall = "OnSpawn";
  167.     end,
  168.  
  169.     YOU_ARE_BEING_WATCHED = function(self,entity,sender)
  170.         
  171.     end,
  172.  
  173.  
  174.     LEFT_LEAN_ENTER = function(self,entity,sender)
  175.         entity:SelectPipe(0,"lean_left_attack");
  176.     end,
  177.  
  178.     RIGHT_LEAN_ENTER = function(self,entity,sender)
  179.         entity:SelectPipe(0,"lean_right_attack");
  180.     end,
  181.  
  182.  
  183.     SWITCH_TO_MORTARGUY = function(self,entity,sender)
  184.         local mounted = AI:FindObjectOfType(entity:GetPos(),200,AIAnchor.USE_THIS_MOUNTED_WEAPON);        
  185.         if (mounted) then
  186.             entity:SelectPipe(0,"goto_mounted_weapon",mounted);
  187.         end
  188.  
  189.     end,
  190.  
  191.  
  192.     RETURN_TO_FIRST = function( self, entity, sender )
  193.         entity.EventToCall = "OnSpawn";    
  194.         entity:Readibility("INTERESTED_TO_IDLE");
  195.     end,
  196.  
  197.     -- Everyone has to be able to warn anyone around him that he died
  198.     --------------------------------------------------
  199.     OnDeath = function ( self, entity, sender)
  200.  
  201.         if (AI:GetGroupCount(entity.id) == 2) then
  202.             -- tell nearest to you to go to reinforcement
  203.             AI:Signal(SIGNALFILTER_NEARESTINCOMM, 1, "GoForReinforcement",entity.id);
  204.         end
  205.         -- tell your friends that you died anyway regardless of wheteher someone goes for reinforcement
  206.  
  207.         if (AI:GetGroupCount(entity.id) > 0) then
  208.             -- tell your nearest that someone you have died only if you were not the only one
  209.             AI:Signal(SIGNALFILTER_NEARESTINCOMM, 1, "OnGroupMemberDiedNearest",entity.id); 
  210.         else
  211.             -- tell anyone that you have been killed, even outside your group
  212.             AI:Signal(SIGNALFILTER_ANYONEINCOMM, 1, "OnSomebodyDied",entity.id);
  213.         end
  214.         
  215.     end,
  216.  
  217.  
  218.     -- What everyone has to do when they get a notification that someone died
  219.     --------------------------------------------------
  220.     OnGroupMemberDiedNearest = function ( self, entity, sender)
  221.  
  222.         if (entity.ai) then 
  223.             entity:MakeAlerted();
  224.  
  225.             entity:Readibility("FRIEND_DEATH",1);
  226.  
  227.             -- bounce the dead friend notification to the group (you are going to investigate it)
  228.             AI:Signal(SIGNALFILTER_GROUPONLY, 1, "OnGroupMemberDied",entity.id);
  229.         else
  230.             -- vehicle bounce the signals further
  231.             AI:Signal(SIGNALFILTER_NEARESTINCOMM, 1, "OnGroupMemberDiedNearest",entity.id);
  232.         end
  233.     end,
  234.  
  235.     ---------------------------------------------
  236.     OnGroupMemberDied = function( self, entity, sender)
  237.         entity:MakeAlerted();
  238.         entity:InsertSubpipe(0,"DRAW_GUN");
  239.     end,
  240.  
  241.     -- reinforcements work the same for everyone
  242.     --------------------------------------------------
  243.     GoForReinforcement = function ( self, entity, sender)
  244.         local ReinforcePoint = AI:FindObjectOfType(entity.id,100,AIAnchor.AIANCHOR_REINFORCEPOINT);
  245.  
  246.  
  247.         if (ReinforcePoint) then 
  248.  
  249.  
  250.             entity:ChangeAIParameter(AIPARAM_GROUPID,999);            
  251.  
  252.             entity:Readibility("GET_REINFORCEMENTS",1);
  253.  
  254.             -- make myself change behaviour to ignore everything
  255.             AI:Signal(0, 1, "IGNORE_ALL_ELSE",entity.id);
  256.         
  257.             entity:SelectPipe(0,"AIS_GoForReinforcement",ReinforcePoint);
  258.             if (entity.AI_GunOut==nil) then    
  259.                 entity:InsertSubpipe(0,"DRAW_GUN");
  260.             end
  261.         end
  262.     end,
  263.  
  264.     -- and everyone has to be able to respond to an invitation to join a group
  265.     --------------------------------------------------
  266.     JoinGroup = function (self, entity, sender)
  267.         entity:ChangeAIParameter(AIPARAM_GROUPID,AI:GetGroupOf(sender.id));
  268.         entity:SelectPipe(0,"AIS_LookForThreat");
  269.     end,
  270.  
  271.     UNCONDITIONAL_JOIN = function (self, entity, sender)
  272.         entity:ChangeAIParameter(AIPARAM_GROUPID,AI:GetGroupOf(sender.id));
  273.     end,
  274.  
  275.  
  276.     CONVERSATION_START = function (self,entity, sender)
  277.         if (entity.CurrentConversation) then 
  278.             entity.CurrentConversation:Start();
  279.         end
  280.     end,
  281.  
  282.     
  283.     --------------------------------------------------
  284.     CONVERSATION_REQUEST = function (self,entity, sender)
  285.  
  286.         if (sender and (entity~=sender)) then    
  287.             if (sender.CurrentConversation:Join(entity)) then
  288.                 entity:SelectPipe(0,"stand_timer",sender.id);
  289.                 entity:InsertSubpipe(0,"simple_approach_to",sender.id);
  290.                 AI:Signal(0,1,"CONVERSATION_REQUEST",sender.id);
  291.             end
  292.         end
  293.     end,
  294.  
  295.     --------------------------------------------------
  296.     CONVERSATION_REQUEST_INPLACE = function (self,entity, sender)
  297.  
  298.         if (sender and (entity~=sender)) then    
  299.             if (sender.CurrentConversation:Join(entity)) then
  300.                 AI:Signal(0,1,"CONVERSATION_REQUEST_INPLACE",sender.id);
  301.                 entity.CurrentConversation:Start();
  302.             end
  303.         end
  304.     end,
  305.  
  306.     --------------------------------------------------
  307.     OFFER_JOIN_TEAM  = function (self,entity, sender)
  308.         if (entity~=sender) then    
  309.             if (AI:GetGroupOf(entity.id) ~= AI:GetGroupOf(sender.id)) then
  310.                 entity:ChangeAIParameter(AIPARAM_GROUPID,AI:GetGroupOf(sender.id));
  311.             end
  312.         end
  313.     end,
  314.  
  315.     ---------------------------------------------    
  316.     SELECT_RED = function (self, entity, sender)
  317.         -- team leader instructs group to split
  318.         if (sender) then
  319.             sender.redteammembers = sender.redteammembers + 1;
  320.         end
  321.         entity:MakeAlerted();
  322.         System:LogToConsole(entity:GetName().." RED");
  323. --        entity:InsertSubpipe(0,"look_at_beacon");
  324.         entity:SelectPipe(0,"look_at_beacon");
  325.     
  326.     end,
  327.     ---------------------------------------------    
  328.     SELECT_BLACK = function (self, entity, sender)
  329.         -- team leader instructs group to split
  330.         if (sender) then
  331.             sender.blackteammembers = sender.blackteammembers + 1;
  332.         end
  333.         entity:MakeAlerted();
  334.         System:LogToConsole(entity:GetName().." BLACK");
  335. --        entity:InsertSubpipe(0,"look_at_beacon");
  336.         entity:SelectPipe(0,"look_at_beacon");
  337.     
  338.     end,
  339.  
  340.  
  341.     --------------------------------------------------    
  342.     SHARED_RELOAD = function (self,entity, sender)
  343.         if (entity.cnt) then
  344.             if (entity.cnt.ammo_in_clip) then
  345.                 if (entity.cnt.ammo_in_clip > 5) then
  346.                     do return end
  347.                 end
  348.             end
  349.         end
  350.  
  351.         System:Log("[AI] ammo in clip "..entity.cnt.ammo_in_clip);
  352.  
  353.         AI:CreateGoalPipe("reload_timeout");
  354.         AI:PushGoal("reload_timeout","timeout",1,entity:GetAnimationLength("reload"));
  355.         entity:InsertSubpipe(0,"reload_timeout");
  356.  
  357.         entity:StartAnimation(0,"reload",4);
  358. --        if (AI:GetGroupCount(entity.id) > 1) then
  359. --            AI:Signal(SIGNALID_READIBILITY, 1, "RELOADING",entity.id);
  360. --        end
  361.         BasicPlayer.Reload(entity);    
  362.     end,
  363.  
  364.     --------------------------------------------------
  365.     SHARED_GRENADE_THROW_OR_NOT = function(self,entity,sender)
  366.         entity:InsertSubpipe(0,"unconditional_grenade");
  367.     end,
  368.  
  369.     --------------------------------------------------
  370.     SHARED_GRANATE_THROW_ANIM = function(self,entity,sender)
  371.         entity:StartAnimation(0,"grenade",4);
  372.         entity.DROP_GRENADE = 1;
  373.     end,
  374.  
  375.     --------------------------------------------------
  376.     SHARED_PLAYLEFTROLL = function(self,entity,sender)
  377.         entity:StartAnimation(0,"rollleft",3);
  378.     end,
  379.  
  380.     --------------------------------------------------
  381.     SHARED_PLAYRIGHTROLL = function(self,entity,sender)
  382.         entity:StartAnimation(0,"rollright",3);
  383.     end,
  384.  
  385.     --------------------------------------------------
  386.     SHARED_TAKEOUTPIN = function(self,entity,sender)
  387.         entity:StartAnimation(0,"signal_inposition",3);
  388.     end,
  389.  
  390.     ------------------------------ Animation -------------------------------
  391.     death_recognition = function (self, entity, sender)
  392.         local XRandom = random(1,3)
  393.         if (XRandom == 1) then
  394.             entity:StartAnimation(0,"death_recognition1");
  395.         elseif (XRandom == 2) then
  396.             entity:StartAnimation(0,"death_recognition2");
  397.         elseif (XRandom == 3) then
  398.             entity:StartAnimation(0,"death_recognition3");
  399.         end
  400.     end,
  401.     ---------------------------------------------        
  402.     PlayRollLeftAnim = function (self, entity, sender)
  403.         entity:StartAnimation(0,"rollleft",3);
  404.     end,
  405.     ------------------------------------------------------------------------
  406.     PlayRollRightAnim = function (self, entity, sender)
  407.         entity:StartAnimation(0,"rollright",3);
  408.     end,
  409.     
  410.  
  411.     --------------------------------------------------
  412.     SHARED_ENTER_ME_VEHICLE = function( self,entity, sender )
  413.  
  414.         System:Log("SHARED_ENTER_ME_VEHICLE");
  415.  
  416.         if( entity.ai == nil ) then return end
  417.     
  418.  
  419.         local vehicle = sender;
  420.         if (vehicle) then
  421.             
  422.             -- not enter hevicle if there is a human driver inside
  423.             if(vehicle.driverT and vehicle.driverT.entity and (not vehicle.driverT.entity.ai)) then return end
  424.             
  425.             System:Log("About to enter vehicle");
  426.             if( vehicle:AddDriver(entity)==1 ) then                -- try to be driver            
  427.                 AI:Signal(0, 1, "entered_vehicle",entity.id);
  428.                 do return end    
  429.             elseif( vehicle:AddGunner(entity)==1 ) then        -- if not driver - try to be gunner            
  430.                 AI:Signal(0, 1, "entered_vehicle",entity.id);
  431.                 do return end    
  432.             elseif( vehicle:AddPassenger(entity)==1 ) then                -- if not gunner - try to be passenger
  433.                 AI:Signal(0, 1, "entered_vehicle",entity.id);
  434.                 do return end    
  435.             end
  436.         end
  437.     end,
  438.  
  439.     ---------------------------------------------
  440.     at_boatenterspot = function(self,entity,sender)
  441.         entity.theVehicle:DoEnter( entity );
  442.         
  443.  
  444.         
  445.         -- entity:StartAnimation(0,"arm_on_shoulder",1,0.4);
  446.     end,
  447.  
  448.     ---------------------------------------------
  449.     OnNoAmmo = function( self, entity, sender)
  450. --        entity.cnt:SelectNextWeapon();
  451.     end,
  452.  
  453.     ---------------------------------------------
  454.     OnReceivingDamage = function(self,entity,sender)
  455.     end,
  456.  
  457.     ------------------------------------------------------    
  458.     -- ANIMATION CONTROL FOR GETTING DOWN AND UP BETWEEN STANCES
  459.     DEFAULT_CURRENT_TO_CROUCH = function( self, entity, sender)
  460.         -- this doesn't have an animation from any stance
  461.     end,
  462.     ------------------------------------------------------
  463.     DEFAULT_CURRENT_TO_PRONE = function( self, entity, sender)
  464.         -- this doesn't have an animation from crouch
  465.         if ((entity.cnt.crouching==nil) and (entity.cnt.proning==nil)) then
  466.             -- the guy was standing, so play animation getdown
  467.             entity:StartAnimation(0,"pgetdown");
  468.         end
  469.     end,
  470.     ------------------------------------------------------
  471.     DEFAULT_CURRENT_TO_STAND = function( self, entity, sender)
  472.         -- this doesn't have an animation from crouch
  473.         if (entity.cnt.proning) then 
  474.             entity:StartAnimation(0,"pgetup");
  475.         end
  476.     end,
  477.     ------------------------------------------------------
  478.     DEFAULT_GO_KNEEL = function( self, entity, sender)
  479.         -- this doesn't have an animation from any stance
  480.     --    if ((entity.cnt.crouching==nil) and (entity.cnt.proning==nil)) then
  481.             -- the guy was standing, so play animation to kneeldown
  482.  
  483.             entity:StartAnimation(0,"kneel_start",2);
  484.             entity:StartAnimation(0,"kneel_idle_loop");
  485.     --    end
  486.     end,
  487.     ------------------------------------------------------
  488.     DEFAULT_UNKNEEL = function( self, entity, sender)
  489.         -- this doesn't have an animation from any stance
  490.     --    if ((entity.cnt.crouching==nil) and (entity.cnt.proning==nil)) then
  491.             entity:StartAnimation(0,"sidle");
  492.             entity:StartAnimation(0,"kneel_end",2);
  493.     --    end
  494.     end,
  495.     ------------------------------------------------------
  496.  
  497.     GO_REFRACTIVE  = function(self,entity,sender)
  498.         entity:GoRefractive();    
  499.     end,
  500.     ------------------------------------------------------
  501.     GO_VISIBLE  = function(self,entity,sender)
  502.         entity:GoVisible();
  503.     end,
  504.  
  505.  
  506.  
  507.     FLASHLIGHT_ON = function(self,entity,sender)    
  508.         entity.cnt:SwitchFlashLight(1);
  509.         entity:ChangeAIParameter(AIPARAM_SIGHTRANGE,entity.PropertiesInstance.sightrange*3);
  510.         entity:ChangeAIParameter(AIPARAM_FOV,60);        
  511.     end,
  512.     FLASHLIGHT_OFF  = function(self,entity,sender)
  513.         entity.cnt:SwitchFlashLight(0);
  514.         entity:ChangeAIParameter(AIPARAM_SIGHTRANGE,entity.PropertiesInstance.sightrange);
  515.         entity:ChangeAIParameter(AIPARAM_FOV,entity.Properties.horizontal_fov);    
  516.     end,
  517.  
  518.  
  519.     ------------------------------------------------------
  520.     -- special Harry-urgent-needed-blind-behaviour-hack -- 
  521.     ------------------------------------------------------
  522.     LIGHTS_OFF  = function(self,entity,sender)
  523.         entity:ChangeAIParameter(AIPARAM_SIGHTRANGE,0.1);    
  524.     end,
  525.     ------------------------------------------------------
  526.     LIGHTS_ON  = function(self,entity,sender)
  527.         entity:ChangeAIParameter(AIPARAM_SIGHTRANGE,entity.PropertiesInstance.sightrange);    
  528.     end,
  529.  
  530.     APPLY_MELEE_DAMAGE = function(self,entity,sender)
  531. --        if (entity.cnt.melee_attack == nil) then
  532. --            entity.cnt.melee_attack = 1;
  533. --            local target = AI:GetAttentionTargetOf(entity.id);
  534. --            if (type(target) == "table") then
  535. --                entity.cnt.melee_target = target;
  536. --            else
  537. --                entity.cnt.melee_target = nil;
  538. --            end
  539. --            if (entity.ImpulseParameters) then 
  540. --                entity.ImpulseParameters.pos = entity:GetPos();
  541. --                local power = entity.ImpulseParameters.impulsive_pressure;
  542. --                entity.ImpulseParameters.impulsive_pressure=2000;
  543. --                entity:ApplyImpulseToEnvironment(entity.ImpulseParameters);
  544. --                entity.ImpulseParameters.impulsive_pressure=power;
  545. --            end
  546. --        end
  547.     end,
  548.  
  549.     RESET_MELEE_DAMAGE = function(self,entity,sender)
  550. --        if (entity.cnt.melee_attack ~= nil) then
  551. --            entity.cnt.melee_attack = nil;
  552. --        end
  553.     end,
  554.  
  555.  
  556.     ---------------------------------------------
  557.     MUTANT_SELECT_IDLE = function ( self, entity, sender)
  558.         entity:SelectPipe(0,"mutant_idling");
  559.     end,
  560.     ---------------------------------------------
  561.     MUTANT_PLAY_IDLE_ANIMATION = function ( self, entity, sender)
  562.         local rnd = random(1,15);
  563.         
  564.         if (rnd>13) then
  565.             entity:SelectPipe(0,"mutant_random_walk");
  566.         elseif (rnd>10) then
  567.             entity:SelectPipe(0,"mutant_random_look");
  568.         else 
  569.             local MyAnim = Mutant_IdleManager:GetIdle(entity);
  570.             if (MyAnim) then
  571.                 entity:InsertAnimationPipe(MyAnim.Name);    
  572.             end
  573.         end
  574.     end,
  575.     ------------------------------------------------------------------------ 
  576.     HIDE_GUN = function (self,entity)
  577.         entity.cnt:DrawThirdPersonWeapon(0);        
  578.     end,
  579.     ------------------------------------------------------------------------ 
  580.     UNHIDE_GUN = function (self,entity)
  581.         entity.cnt:DrawThirdPersonWeapon(1);        
  582.     end,
  583.     ------------------------------------------------------------------------ 
  584.  
  585.     SHARED_DRAW_GUN_ANIM = function (self,entity)
  586.  
  587.         if (entity.cnt:GetCurrWeapon() ~= nil) then     
  588.             if (entity.AI_GunOut==nil) then 
  589.                 local rnd=random(1,3);
  590.                 local anim_name = "draw0"..rnd;
  591.                 entity:StartAnimation(0,anim_name,3);    
  592.                 local anim_dur = entity:GetAnimationLength(anim_name);    
  593.                 entity:TriggerEvent(AIEVENT_ONBODYSENSOR,anim_dur);
  594.                 AI:EnablePuppetMovement(entity.id,0,anim_dur);
  595.                 entity.AI_GunOut = 1;
  596.             end
  597.         end
  598.     end,
  599.     ------------------------------------------------------------------------ 
  600.     SHARED_HOLSTER_GUN_ANIM = function (self,entity)
  601.         if (entity.AI_GunOut) then 
  602.             local rnd=random(1,3);
  603.             --AI:MakePuppetIgnorant(entity.id,1);
  604.             entity:StartAnimation(0,"holster0"..rnd,4);        
  605.             entity.AI_GunOut = nil;
  606.         end
  607.     end,
  608.     ------------------------------------------------------------------------ 
  609.     SHARED_REBIND_GUN_TO_HANDS = function (self,entity)
  610.         --entity.cnt:HoldGun();        
  611.         --AI:MakePuppetIgnorant(entity.id,0);
  612.         entity.AI_GunOut = 1;
  613.     end,
  614.     ------------------------------------------------------------------------ 
  615.     SHARED_REBIND_GUN_TO_BACK = function (self,entity)
  616.         --entity.cnt:HolsterGun();        
  617.         --AI:MakePuppetIgnorant(entity.id,0);
  618.         entity.AI_GunOut = nil;
  619.     end,
  620.     ------------------------------------------------------------------------ 
  621.  
  622.     DO_THREATENED_ANIMATION = function(self,entity,sender)
  623.  
  624.         local rnd = random(1,3);        
  625.         entity:InsertAnimationPipe("_surprise0"..rnd,3);
  626.         local anim_dur = entity:GetAnimationLength("_surprise0"..rnd);    
  627.         entity:TriggerEvent(AIEVENT_ONBODYSENSOR,anim_dur);
  628.         AI:EnablePuppetMovement(entity.id,0,anim_dur);
  629.     end,
  630.     ---------------------------------------------
  631.     SHARED_PLAY_CURIOUS_ANIMATION = function(self,entity,sender)
  632.  
  633.         local rnd = random(1,2);        
  634.         entity:InsertAnimationPipe("_curious"..rnd);
  635.     end,
  636.     ---------------------------------------------
  637.  
  638.     DO_SOMETHING_IDLE = function( self,entity , sender)
  639.  
  640.         if (entity:MakeMissionConversation()) then        -- try talking to someone
  641.             entity:CheckFlashLight();
  642.             do return end
  643.         end
  644.  
  645.  
  646.         if (entity:MakeRandomConversation()) then        -- try talking to someone
  647.             entity:CheckFlashLight();
  648.             do return end
  649.         end
  650.  
  651.         if (entity:DoSomethingInteresting()) then        -- piss, smoke or whatever
  652.             entity:CheckFlashLight();
  653.             do return end
  654.         end
  655.  
  656.         -- always make at least an animation :)
  657.         entity:MakeRandomIdleAnimation();         -- make idle animation
  658.         entity:CheckFlashLight();
  659.     end,
  660.     ---------------------------------------------
  661.     GOING_TO_TRIGGER = function (self, entity, sender)
  662.         entity.RunToTrigger = 1;
  663.          if ( sender.id == entity.id ) then
  664.              entity:InsertSubpipe(0,"run_to_trigger",entity.AI_ALARMNAME);
  665.          end
  666.         
  667.     end,
  668.     ---------------------------------------------
  669.     THROW_FLARE = function (self, entity, sender)
  670.  
  671.          if ( sender.id == entity.id ) then
  672.             entity:InsertSubpipe(0,"throw_flare");
  673.          end
  674.     end,
  675.  
  676.     SWITCH_GRENADE_TYPE = function (self, entity, sender)
  677.         BasicPlayer.SelectGrenade(entity,"HandGrenade");
  678.     end,
  679.  
  680.  
  681.     MAKE_STUNNED_ANIMATION = function (self, entity, sender)
  682.  
  683.         if (entity.BLINDED_ANIM_COUNT) then
  684.             local rnd = random(0,entity.BLINDED_ANIM_COUNT);
  685.             local anim_name = format("blind%02d",rnd);
  686.             entity:InsertAnimationPipe(anim_name,4);
  687.             local dur = entity:GetAnimationLength(anim_name);
  688.             AI:EnablePuppetMovement(entity.id,0,dur+3);    -- added the timeouts in the pipe
  689.             entity:TriggerEvent(AIEVENT_ONBODYSENSOR,dur+3);
  690.         else
  691.             Hud:AddMessage("==================UNACCEPTABLE ERROR====================");
  692.             Hud:AddMessage("Entity "..entity:GetName().." tried to make blinded anim, but no blindXX anims for his character.");
  693.             Hud:AddMessage("==================UNACCEPTABLE ERROR====================");
  694.         end
  695.         
  696.     end,
  697.  
  698.  
  699.     ---------------------------------------------
  700.     FLASHBANG_GRENADE_EFFECT = function (self, entity, sender)
  701.         if (entity.ai) then
  702.             entity:InsertSubpipe(0,"stunned");
  703.             entity:Readibility("FLASHBANG_GRENADE_EFFECT",1);
  704.         end
  705.         
  706.     end,
  707.  
  708.     ---------------------------------------------
  709.     SHARED_BLINDED = function (self, entity, sender)
  710.     end,
  711.  
  712.     ---------------------------------------------
  713.     SHARED_UNBLINDED = function (self, entity, sender)
  714.         entity:StartAnimation(0,"NULL",4);
  715.     end,
  716.  
  717.     ---------------------------------------------
  718.     SHARED_PLAY_GETDOWN_ANIM = function (self, entity, sender)
  719.         local rnd= random(1,2);
  720.         entity:InsertAnimationPipe("duck"..rnd.."_down",3);
  721.     end,
  722.     ---------------------------------------------
  723.     SHARED_PLAY_GETUP_ANIM = function (self, entity, sender)
  724.         local rnd= random(1,2);
  725.         entity:InsertAnimationPipe("duck"..rnd.."_up",3);
  726.     end,
  727.     ---------------------------------------------
  728.     SHARED_PLAY_DAMAGEAREA_ANIM = function (self, entity, sender)
  729.         local rnd= random(1,2);
  730.         entity:InsertAnimationPipe("duck"..rnd.."_up",3);
  731.     end,
  732.     
  733.  
  734.     exited_vehicle = function( self,entity, sender )
  735.  
  736. --        AI:Signal(SIGNALID_READIBILITY, 2, "AI_AGGRESSIVE",entity.id);    
  737. --        entity.EventToCall = "OnSpawn";    
  738.         AI:Signal(0,1,"OnSpawn",entity.id);
  739.     end,
  740.     
  741. }